//
//  ThirdViewController.m
//  页面的跳转
//
//  Created by clz on 2019/9/8.
//  Copyright © 2019 clz. All rights reserved.
//

#import "ThirdViewController.h"
#import "FirstViewController.h"

@interface ThirdViewController ()

@end

@implementation ThirdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Third";
    self.view.backgroundColor = [UIColor orangeColor];
    
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setTitle:@"返回" forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    button1.frame = CGRectMake(0, 200, 100, 40);
    [button1 setBackgroundColor:[UIColor whiteColor]];
    [button1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
}

- (void)back:(UIButton *)sender{
//    [self.navigationController popViewControllerAnimated:YES];
//    [self.navigationController popToRootViewControllerAnimated:YES];
    
    
    for (UIViewController *tmpVC in self.navigationController.viewControllers) {
        if ([tmpVC isKindOfClass:[FirstViewController class]]) {
            [self.navigationController popToViewController:tmpVC animated:YES];
            break;
        }
    }
}



@end
